package howl.Servlets;



import howl.model.PMF;
import howl.types.*;

import java.io.IOException;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@SuppressWarnings("serial")
public class deleteServlet extends HttpServlet {
	
	public static boolean cleanme = false;
	
	public static Class[] classes = new Class[]{TableDescriptor.class,Entry.class,Datum.class,Alarm.class,Report.class,AccessGroup.class,DataProvider.class};
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		if(cleanme){
			
		PersistenceManager pm = PMF.get().getPersistenceManager();
		for(int i = 0; i<classes.length; i++){
		Query query = pm.newQuery(classes[i]);
	    query.deletePersistentAll();
		}
		
		resp.setContentType("text/plain");
		resp.getWriter().println("Deleted it");
		}
		
	}
}
